package drds.data_propagate.entry;

import drds.common.$;
import drds.data_propagate.common.utils.ToStringStyle;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;

public class ClientId implements Serializable {

    private static final long serialVersionUID = -8262100681930834834L;
    @Setter
    @Getter
    private String taskId;
    @Setter
    @Getter
    private short clientId;
    @Setter
    @Getter
    private String filter;

    public ClientId() {

    }

    public ClientId(String taskId, short clientId) {
        this.clientId = clientId;
        this.taskId = taskId;
    }

    public ClientId(String taskId, short clientId, String filter) {
        this.clientId = clientId;
        this.taskId = taskId;
        this.filter = filter;
    }

    public Boolean hasFilter() {
        if (filter == null) {
            return false;
        }
        return $.isNotNullAndNotEmpty(filter);
    }


    public String toString() {
        return ToStringStyle.toString(this);
    }

    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + clientId;
        result = prime * result + ((taskId == null) ? 0 : taskId.hashCode());
        return result;
    }

    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (!(obj instanceof ClientId)) {
            return false;
        }
        ClientId other = (ClientId) obj;
        if (clientId != other.clientId) {
            return false;
        }
        if (taskId == null) {
            if (other.taskId != null) {
                return false;
            }
        } else if (!taskId.equals(other.taskId)) {
            return false;
        }
        return true;
    }

}
